<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        img {
            width: 200px;
            height: 400px;
        }
    </style>
</head>

<body>
    <script>
        window.addEventListener('load', function() {
            var img = document.querySelector("img");
            var btn = document.querySelector('button');
            var time1 = setTimeout(fn, 5000);

            function fn() {
                img.style.display = 'none';
            }
            btn.addEventListener('click', function() {
                clearTimeout(time1)
            })
        })
    </script>
    <img src="../images/pic1.jpg" alt="">
    <button>点击</button>
</body>

</html>